Pelago Revolutionizes Substance Use Disorder Support with AI-Powered Personalization, Halving Care Team Response Times

Healthcare organizations globally grapple with a profound scaling dilemma: how to expand patient reach and member bases without sacrificing the deeply personalized interactions crucial for effective care, all while preventing clinician burnout and maintaining service quality. This challenge is particularly acute in specialized fields like substance use disorder (SUD) treatment, where continuous, empathetic, and context-aware communication is paramount. Addressing this critical need, Pelago, a leading digital health company focused on SUD support, has successfully developed and deployed an innovative AI-powered solution. Leveraging a suite of Amazon Web Services (AWS) serverless and AI technologies, including Amazon Bedrock and AWS Lambda, Pelago’s engineering team achieved this breakthrough in a remarkable two weeks, resulting in an event-driven AI assistant that generates contextually aware suggestions for its care teams. This system not only preserves the essential human-in-the-loop oversight demanded by healthcare but also drastically reduces traditional development timelines and the operational overhead associated with managing complex infrastructure.
The Pressing Need for Scalable, Personalized Care in SUD Treatment
Substance Use Disorder represents a significant public health crisis, impacting millions worldwide. In the United States alone, an estimated 20.4 million adults had an SUD in 2022, according to the Substance Abuse and Mental Health Services Administration (SAMHSA). Effective treatment often hinges on sustained, personalized support, including one-on-one coaching, medication management, and behavioral therapy. Pelago stands at the forefront of this battle, operating a digital clinic that provides comprehensive support to members across the US, assisting with recovery journeys for alcohol, tobacco, stimulants, cannabis, and opioid use disorder, as well as associated behaviors.
The inherent challenge for Pelago’s care teams, comprised of dedicated coaches, lies in managing active conversations with dozens of members simultaneously. Each interaction requires a deep understanding of weeks, if not months, of prior context. Manually drafting responses that reflect this intricate history is time-consuming and often unsustainable, directly contributing to potential delays in care and increased workload for coaches. The demand for personalized care is escalating, with patients increasingly expecting tailored, timely interactions. Simultaneously, healthcare providers face immense pressure to improve efficiency and scalability without compromising the quality or human touch of their services.
Overcoming Interconnected Constraints in Behavioral Health AI Development
When Pelago’s engineering team embarked on developing an AI assistant, they confronted a multifaceted array of constraints specific to behavioral health and highly regulated environments. The foundational principle was that behavioral health conversations evolve over weeks and months, necessitating an AI assistant capable of grasping the entire long-term conversation history, not just recent messages. An AI limited to short-term memory would be ineffective, failing to provide meaningful or safe suggestions.
Crucially, the "human-in-the-loop" oversight was deemed non-negotiable. The system was designed to generate suggestions for Pelago’s care team, not automated responses. This critical distinction ensures that every piece of AI-generated feedback is meticulously read, evaluated, and adapted by a human coach before it ever reaches a member, thereby maintaining clinical safety, empathy, and professional judgment.

Beyond clinical safety, stringent Protected Health Information (PHI) requirements added another layer of complexity. All data, especially sensitive health information, had to remain strictly within Pelago’s AWS environment, with all AI integrations operating entirely within existing Amazon Virtual Private Cloud (VPC) infrastructure and absolutely no exposure to the public internet. This strict adherence to data privacy and security protocols, critical for HIPAA compliance, was a foundational design principle.
Practical operational constraints also played a significant role. Care team members require information instantly when accessing a conversation. However, generating contextually relevant content by processing dozens, or even hundreds, of prior messages through a large language model (LLM) is computationally intensive and time-consuming. Long wait times were unacceptable for coaches managing numerous conversations per shift. The engineering team was tasked with delivering a solution that was fast, secure, fully auditable, and compliant, all while pre-generating contextual suggestions without hindering the user experience.
A Rapid, Event-Driven Serverless Solution: The Architectural Blueprint
Pelago’s breakthrough solution centers on an event-driven serverless architecture that intelligently separates concerns. Recognizing that synchronous, real-time LLM processing would block the user experience, the team opted for an asynchronous approach. Each incoming member message is treated as an independent event, allowing the system to fan out processing to various consumers without coupling them to the message delivery path. This design choice enables the seamless addition of new consumers, such as the AI assistant, without impacting existing components or code. Moreover, by running each processing step in its own AWS Lambda function, spikes in inference requests do not compromise message delivery or other critical processes.
The full end-to-end architecture, a testament to modern cloud engineering, utilizes Amazon Simple Notification Service (Amazon SNS) for robust message fanout and AWS Lambda functions for efficient, scalable processing. Here’s a simplified breakdown of the workflow:
- Member Message Ingestion: When a member or coach sends a message within the Pelago application, it is captured by the system.
- SNS Topic Publication: The system publishes a standardized payload containing essential message metadata (e.g.,
identityId,messageId,sender,timestamp,conversationId) to a central Amazon SNS topic. This SNS topic acts as a highly scalable message bus. - Fanout to Lambda Subscribers: Amazon SNS, a fully managed pub/sub messaging service, automatically delivers this event to multiple subscribed AWS Lambda functions in parallel. This concurrent processing is key to efficiency.
- Metadata Storage Lambda: Writes message metadata to a MySQL database for reporting and analytical purposes.
- Analytics Lambda: Sends events to Amplitude for in-depth product analytics, providing insights into user engagement and application performance.
- Push Notification Lambda: Triggers mobile notifications for coaches, ensuring timely awareness of new messages.
- Chat Assistant Lambda: This is the core component for AI generation. It initiates the process of generating AI-powered suggestions using Amazon Bedrock.
- Asynchronous AI Generation: The Chat Assistant Lambda, upon receiving an event, retrieves the full conversation history from DynamoDB, formats it, invokes Amazon Bedrock for inference, and stores the generated suggestion back into a MySQL database. This process occurs in the background.
- Instant Retrieval for Coaches: When a care team member opens a conversation on their dashboard, the front end instantly retrieves the pre-generated suggested messages from MySQL.
This decoupled pattern ensures that each member’s PHI is processed separately and remains entirely within Pelago’s AWS boundary. A failure or processing spike for one member does not disrupt or impact others, guaranteeing system resilience. Because inference happens asynchronously, care team members do not experience delays caused by LLM processing. Suggested messages are already pre-generated and stored, ready for immediate retrieval, resulting in perceived response times under 100 milliseconds.
The serverless nature of the architecture provides inherent organic scaling. Each Lambda function automatically scales horizontally based on current traffic, effortlessly handling surges during peak hours and scaling down during quiet periods without requiring manual pre-provisioning or complex scaling configurations. This pay-per-invocation model optimizes cost efficiency, as Pelago only pays for the compute resources consumed.
Deep Dive into AI Generation with Amazon Bedrock

The Chat Assistant Lambda is responsible for the computationally intensive AI generation process. Its multi-step workflow is meticulously designed for accuracy, speed, and contextual relevance:
- Conversation History Retrieval: Behavioral health conversations can span dozens, even hundreds, of messages over weeks. The AI assistant requires this comprehensive context to generate truly useful suggestions. The Lambda function queries Amazon DynamoDB, a high-performance NoSQL database, for all previous messages in the conversation. DynamoDB’s single-digit millisecond read performance ensures that even lengthy conversations (50+ messages) are typically retrieved in under 20ms.
- Context Preparation and Formatting: The retrieved messages are transformed into a structured conversation history format suitable for Amazon Bedrock. This meticulous formatting ensures that the LLM receives the full, chronological context, such as:
[User]: Hi, I'm struggling with cravings today [Coach]: I hear you. Cravings can be really tough. What's happening right now that's making this moment difficult? [User]: I'm at a party and everyone is drinking. I feel left out. [Coach]: That's a really challenging situation, and it's completely understandable to feel that way... [User]: I ended up leaving early. Feeling proud but also kind of sad. - Amazon Bedrock Inference with Claude Models: The Lambda function then uses the Amazon Bedrock Runtime API to invoke Claude models, a family of powerful foundation models. The prompt engineering is a critical aspect, meticulously crafted to focus on empathy and validation, helping the model acknowledge the member’s feelings rather than immediately offering advice. It is also tuned to maintain contextual continuity, referencing earlier mentions by the member, and to avoid false optimism or dismissive language. Suggestions are kept concise, mimicking the natural flow of text-based coaching conversations.
Rapid Development and Unprecedented Business Impact
The Pelago team’s journey from technical designs to first production deployment was extraordinarily swift, completed in just two weeks. This timeline included two days for architecture and model selection with the clinical team, three days for building the core Lambda functions, three days for integration testing and prompt refinement, and two final days for deployment and monitoring. This rapid iteration capability, largely attributable to the use of managed serverless services, highlights the agility cloud platforms offer.
The system yielded strong early results and tangible business impact. Response preparation times for care teams dropped by an average of 40%, significantly enhancing efficiency and allowing coaches to engage with more members or dedicate more time to complex cases. Internally, Pelago measured that 79.6% of AI suggestions were rated as "helpful" by the care team, a testament to the quality and relevance of the AI-generated content.
Operationally, the adoption of serverless services introduced virtually no new overhead. There was no new infrastructure to manage, no servers to patch, and no complex scaling configurations to maintain. The architecture demonstrated its robustness by successfully handling an 8x message volume spike during a seasonal campaign without requiring any configuration changes, underscoring its inherent scalability and resilience.
Implementation Details and Strategic Decisions for Healthcare Compliance
Several key implementation choices were made to meet the rigorous requirements of the healthcare industry, optimize for application-specific traffic patterns, and ensure system reliability:
- PHI Security: Maintaining HIPAA eligibility was paramount. Pelago deployed multiple AWS security features, notably using VPC endpoints for Amazon Bedrock. This ensures that all model invocations remain entirely within Pelago’s private network, preventing PHI from ever traversing the public internet. Data is encrypted at rest in DynamoDB and RDS, all service communications use TLS 1.2+, and IAM policies are strictly scoped with least-privilege permissions. Audit logs of model invocations are emitted to Amazon CloudWatch, capturing only message IDs, not content, for accountability without compromising privacy.
- Polyglot Cross-Runtime Implementation: The engineering team strategically utilized Python for Lambda functions interacting with Amazon Bedrock due to Boto3’s native support and Python’s strengths in string manipulation for prompt engineering. Conversely, the retrieval function was written in TypeScript, aligning with the majority of Pelago’s backend codebase and allowing reuse of shared libraries and Zod schemas for type-safe API contracts. This pragmatic approach leveraged the best language for each specific task.
- Spiky Traffic and Pay-Per-Invocation Compute: Pelago’s US-based traffic exhibits significant spikes, with weekday working hours seeing ten times or more the volume of quiet periods. Lambda’s pay-per-invocation model perfectly aligns with this pattern, automatically scaling out during surges and scaling down during off-peak hours, eliminating idle compute costs. This contrasts with traditional long-lived compute models that often require over-provisioning or complex auto-scaling policies that can lag during sudden demand spikes.
- Optimal Storage and Idempotency: DynamoDB was chosen for conversation messages due to its high write throughput (100+ writes/sec at peak), single-digit millisecond reads, and automatic scaling capabilities. MySQL was selected for assistant suggestions, which have a lighter write load (10-20 writes/sec) but benefit from structured queries, foreign key relationships, and nested analytics joins provided by a relational database. To prevent duplicate Amazon Bedrock invocations—which would waste compute and could surface conflicting suggestions—the Chat Assistant Lambda incorporates an idempotency check, verifying for an existing message in MySQL before generating a new one. A built-in retry mechanism handles transient failures, ensuring suggestions are eventually generated even under momentary capacity constraints.
- Comprehensive Monitoring and Observability: The team implemented robust monitoring using Amazon CloudWatch, tracking key business and operational metrics such as suggestion generation latency, retrieval rate (percentage of generated suggestions used by coaches), and error rates. CloudWatch alarms proactively alert the engineering team to issues like Amazon Bedrock throttling or database connection failures. Coaches also provide explicit feedback via thumbs up/down ratings, which are stored in MySQL for continuous prompt tuning and model evaluation, fostering a cycle of improvement.
Broader Implications and a Vision for the Future of Healthcare

Pelago’s successful implementation sets a compelling precedent for the broader digital health industry and the application of AI in highly regulated sectors. The combination of managed AI services like Amazon Bedrock with serverless event-driven architectures demonstrates that rapid innovation is achievable while rigidly adhering to compliance controls.
This model of pre-generating message suggestions asynchronously, decoupled from the user’s synchronous interaction, offers a blueprint for enhancing clinician efficiency and patient engagement across various healthcare domains. The explicit emphasis on "human-in-the-loop" oversight is critical, ensuring that AI augments, rather than replaces, human expertise and empathy in sensitive areas like behavioral health. This approach assuages common concerns about AI in healthcare, particularly regarding clinical responsibility and patient safety.
"Our mission at Pelago is to make substance use disorder support accessible and deeply personalized," stated a Pelago spokesperson, reflecting on the achievement. "This AI assistant is a game-changer, empowering our coaches to deliver even more timely and contextually rich interactions without increasing their workload. It’s about enhancing the human connection, not diminishing it." An AWS representative added, "Pelago’s innovative use of AWS serverless and AI services exemplifies how cloud technology can accelerate impactful solutions in healthcare. Their rapid deployment and demonstrable results showcase the power of combining agility with robust compliance."
The ability to scale organically with demand, coupled with a pay-per-invocation cost model, positions Pelago to expand its reach significantly, potentially democratizing access to high-quality SUD care. By minimizing operational overhead and maximizing efficiency, Pelago can focus its resources on clinical excellence and continuous innovation, rather than infrastructure management. This strategy is particularly vital in behavioral health, where a severe shortage of qualified providers often limits access to care. AI tools, when deployed responsibly and ethically, can help bridge this gap by enabling existing care teams to be more effective and serve a larger population.
The Pelago journey from concept to a production-ready system in just two weeks illustrates that even small engineering teams in regulated industries can balance the imperatives of moving fast with maintaining an uncompromised compliance posture. As digital health continues to evolve, Pelago’s model offers a powerful example of how AI can be leveraged to deliver deeply personalized, scalable, and secure patient support, ultimately transforming the landscape of behavioral healthcare.







